<?
	class lower_user_reg
	{
		var $key_code = 'sdfs$#%34123423434%%@@@3^$^!@#dfgf45wf33^^^44'; // 私钥
		var $postUrl = "http://u.9wee.com/index.php?module=event&action=lower_user_reg";
		function postQuery ( $postVars )
		{
			if(is_array($postVars))
			{
				foreach($postVars as $key=>$value)
				{
					$postData .= '&'.$key.'='.$value;
				}
				$postUrl = $this->postUrl.$postData;//echo $postUrl;
				$results = file_get_contents ( $postUrl );
				return $results;
			}
		}
		/**发送请求
		*@param string $apply_id 推广员ID
		*@param string $reg_time 注册时间
		*@param string $reg_ip 推广员ID
		*@param string $lower_user_account 下线账号
		*@param string $lower_user_nickname 下线昵称
		*@param string $game_id 下线所属游戏
		*@param string $upper_id 渠道ID
		*@param int money 游戏币
		*/
		function send($apply_id,$reg_time,$reg_ip,$lower_user_account,$lower_user_nickname,$game_id,$upper_id)
		{
			$game_id = 100;
			if ( is_numeric($apply_id) && strlen($apply_id) >= 8 )
			{
				$round_code = rand(1,10000);
				$string = $apply_id.$reg_time.$reg_ip.$round_code.$this->key_code.$lower_user_account.$lower_user_nickname.$game_id;
				$md5_code = md5($string);
				$postArr = array (
					'apply_id' => $apply_id,
					'reg_time' => $reg_time,
					'reg_ip'=>$reg_ip,
					'round_code' => $round_code,
					'lower_user_account' => $lower_user_account,
					'lower_user_nickname'=>$lower_user_nickname,
					'md5_code' => $md5_code,
					'game_id'=>$game_id,
					'upper_id'=>$upper_id
					);//echo "string1=".$string."<br>";
				$this->postQuery ( $postArr );
			}
		}
	}

	if ($_SESSION['union_username'] !='') {
		if(!empty($_GET['q'])){
			$q_ = explode("_",$_GET['q']);			
			if($q_[3] == 1){
				$_GET['q'] = $q_[0]."_".$q_[1]."_".$q_[2];
				$q = explode("_",$_GET['q']);
				$apply_id = $q['0'];
				$game_id = $q['1'];
				$upper_id = $q['2'];
				$reg_time = time();
				$reg_ip = $_SERVER['REMOTE_ADDR'];
				$lower_user_account = $_SESSION['union_username'];
				$lower_user_nickname = $_SESSION['union_nickname'];	

				$lower_user_reg = new lower_user_reg;	
				$lower_user_reg->send($apply_id,$reg_time,$reg_ip,$lower_user_account,$lower_user_nickname,$game_id,$upper_id);

			}
		}
	}
?>